﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;
using System.Threading;
using System.Xml.Serialization;
using System.IO;
using System.Diagnostics;

namespace FileSharer
{
    public class Program
    {
        public static int Main(string[] args)
        {
            if (args.Length > 1)
            {
                Program.DisplayUsage();
                return 1;
            }

            if (args.Length == 0)
            {
                Program.RunAsService();
                return 0;
            }
            else if (args[0].ToLower() == "/console")
            {
                Program.RunAsConsole();
                return 0;
            }
            else
            {
                Program.DisplayUsage();
                return 1;
            }

        }

        private static void DisplayUsage()
        {
            Console.WriteLine("Usage: FileSharer.exe /console");
        }

        private static void RunAsService()
        {
            FileSharerService service = new FileSharerService();
            FileSharerService.Run(service);
        }

        private static void RunAsConsole()
        {
            ChangesetWatcher watcher = new ChangesetWatcher();
            watcher.Start();
            Console.WriteLine("Press ENTER to stop file sharer.");
            Console.ReadLine();
            watcher.Stop();
        }
    }
}
